<!DOCTYPE html>
<html lang="zh-CN">
<head>
<!--  4种方法让SpringMVC接收多个对象 http://blog.csdn.net/lutinghuan/article/details/46820023 -->
<#include "bases/global_style.ftl">
<#include "bases/global_js.ftl">
<style type="text/css">
.sheet-table .radio-inline {
    padding-top: 0!important;
}
.sheet-table.table>tbody>tr>td{
   	vertical-align: middle; 
}
.sheet-table input[type='number']{
   	width: 90px;
  		display: inline-block;
}
.sheet-table .fixation{
   	width: 35%;
}
.sheet-table .fixation2{
   	width: 35%;
}
.sheet-table .fixation3{
   	width: 20%;
}
.sheet-table .fixation4{
   	width: 5%;
}
</style>
</head>

<body>
 
   <#if packagePostageModel.packagePostageDetailModelDetailList??>
     <#assign detailList=packagePostageModel.packagePostageDetailModelDetailList>
   </#if>
 
	<div class="page-container" id="loading">
				<div class="row-fluid">
					<div class="span12">
						<div class="portlet box green">
							<div class="portlet-title">
								<div class="caption">
									<i class="fa fa-cogs"></i><#if id??>修改阶梯资费<#else>新增阶梯资费</#if>
								</div>
	                            <div class="tools">
	                                <a href="javascript:window.location.reload()" class="reload"></a>
	                            </div>
							</div>

							<div class="portlet-body flip-scroll">
							   <form class="form-horizontal" role="form" id="dataform">
							   
							      <input type="hidden" name="id" value="<#if id??>${id}</#if>">
							   
								  <div class="form-group">
								     <label class="col-sm-3 control-label">套餐类型</label>
								     <div class="col-sm-5">
								        <label class="radio-inline">
										  <input type="radio" name="type" class="role1Btn" id="" value="1" checked required> 按里程收费
										</label>
								     </div>
								  </div>
								  
							 	   <div class="form-group">
								      <label class="col-sm-3 control-label">套餐名称<span class="fill-must">*</span></label>
								      <div class="col-sm-5">
								        <input type="text" class="form-control" name="name" placeholder=""  value="<#if packagePostageModel.name??>${packagePostageModel.name}</#if>" required>
								     </div>
								   </div>
								 
								  <div class="form-group">
								     <label class="col-sm-3 control-label">地区<span class="fill-must">*</span></label>
								     <div class="col-sm-8">
								        <label class="radio-inline">
									    	  <input type="radio" name="areaRadio" class="areaRadio" id="allRadio" value="1" <#if packagePostageModel.task=='add'>checked</#if><#if packagePostageModel.areaRadio??><#if packagePostageModel.areaRadio==1>checked</#if></#if> required> 全地区
										</label>
										
								      </div>
									    
								      <div class="col-sm-offset-3 col-sm-8">
										  <label class="radio-inline">
											  <input type="radio" name="areaRadio" class="areaRadio" id="customRadio" value="2"   <#if packagePostageModel.areaRadio??><#if packagePostageModel.areaRadio==2>checked</#if></#if> required> 选择地区
										  </label>
										  <div id="proCityBox">
											  <div style="margin-top: 20px"></div>
											  <label class="radio-inline">省份
												  <select id="provinceids" multiple="multiple" name="provinceids" >
												  </select>
											  </label>
									
											   <div style="margin-top: 20px"></div>
											   <label class="radio-inline">地市
												  <select id="cityids" multiple="multiple" name="cityids" >
												 </select>
											  </label>
										  </div>
								        </div>
								    </div>
								    
								    <div class="">
										<div class="form-group" >
										    <label class="col-sm-3 control-label">单价<span class="fill-must">*</span></label>
										    <div class="role1">
											    <div class="col-sm-3">
											        <input type="number" name="unitprice1" id="unitprice1" class="form-control" placeholder=""  onchange="$(this).next().val($(this).val()*100)"  value="<#if packagePostageModel.unitprice??>${packagePostageModel.unitprice/100}</#if>" required>
											        <input type="hidden"  name="unitprice" value="<#if packagePostageModel.unitprice??>${packagePostageModel.unitprice}</#if>">
											    </div>
										   	 	<div class="col-sm-2 sheet-inputContent" style="padding-left: 0;"> 元 / 公里</div>
										    </div>
										</div>
									</div>  
								   
								   <!-- 按里程收费-->
								  <div class="role1">
									  <div class="form-group">
									    <label class="col-sm-3 control-label">阶梯费用设置<span class="fill-must">*</span></label>
									    <div class="col-sm-9">
									        <table class="table table-condensed table-bordered sheet-table">
									        	<!-- 新版 -->
									        	<tr>
			        								<td class="sheet-tableAction" id="sheet-trPlus" colspan="4"><i class="fa fa-plus-square-o"></i></td>
			        							</tr>
			        							<tr>
			        								<th class="fixation" style="text-align: center;">阶梯里程</th>
													<th class="fixation2" style="text-align: center;">收费模式</th>
													<th class="fixation3" style="text-align: center;">附加费</th>
													<th class="fixation4" style="text-align: center;">操作</th>
			        							</tr>
			        	
			        							<tr>
			        								<td class="fixation">
			        									<input type="number" name="upper" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" value="<#if detailList[1].upper??><#if packagePostageModel.type==1>${detailList[1].upper}</#if></#if>" required>公里&nbsp;以下
										        		<input type="hidden" name="packagePostageDetailModelDetailList[1].upper" value="<#if detailList[1].upper??><#if packagePostageModel.type==1>${detailList[1].upper}</#if></#if>">
			        								</td>
			        		
													<td class="fixation2">
														<label class="radio-inline">
								  							<input type="radio" name="packagePostageDetailModelDetailList[1].mileRadio" value="1" <#if packagePostageModel.task=='add'>checked</#if><#if detailList[1].mileRadio??><#if detailList[1].mileRadio==1><#if packagePostageModel.type==1>checked</#if></#if></#if>  required onclick="$('#lc_mileage1').attr('required','required');"> 按固定里程
														</label>
														<input type="number" id="lc_mileage1" name="lc_mileage1"  class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" value="<#if detailList[1].mileage??><#if packagePostageModel.type==1>${detailList[1].mileage}</#if></#if>" <#if detailList[1].mileRadio??><#if detailList[1].mileRadio==1>required</#if></#if>> 公里收费
									        		    <input type="hidden" name="packagePostageDetailModelDetailList[1].mileage" value="<#if detailList[1].mileage??><#if packagePostageModel.type==1>${detailList[1].mileage}</#if></#if>">
								
														<label class="radio-inline">
								  							<input type="radio" name="packagePostageDetailModelDetailList[1].mileRadio" value="2" <#if detailList[1].mileRadio??><#if detailList[1].mileRadio==2><#if packagePostageModel.type==1>checked</#if></#if></#if>  required onclick="$('#lc_mileage1').removeAttr('required');"> 按单位里程收费
														</label>
													</td>
							
													<td class="fixation3">
														每次加收<input type="number" name="extracharge" class="form-control" placeholder="" onchange="$(this).next().val($(this).val()*100)" value="<#if detailList[1].extracharge??><#if packagePostageModel.type==1>${detailList[1].extracharge/100}</#if></#if>">元
														<input type="hidden" name="packagePostageDetailModelDetailList[1].extracharge" value="<#if detailList[1].extracharge??><#if packagePostageModel.type==1>${detailList[1].extracharge}</#if></#if>">
													</td>
													<td class="fixation4"></td>
			        							</tr>

									        	<tbody id="sheet-tbody">
									        	   <#if detailList?? && packagePostageModel.type==1>
									        	   <#list detailList  as item>
									        	   	 <#if item_index gt 1>
										        	     <tr class="plusContent">
											        		<td class="fixation">
	                                                            <input type="number" name="lower${item_index}"  class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" value="<#if item.lower??>${item.lower}</#if>" required>公里 &nbsp;至
											        		    <input type="hidden"   name="packagePostageDetailModelDetailList[${item_index}].lower"   value="<#if item.lower??>${item.lower}</#if>">
											        		    <input type="number" name="upper${item_index}"  class="form-control" lowerplaceholder="" onchange="$(this).next().val($(this).val())" value="<#if item.upper??>${item.upper}</#if>" required>公里&nbsp;以下
											        		    <input type="hidden"  name="packagePostageDetailModelDetailList[${item_index}].upper"   value="<#if item.upper??>${item.upper}</#if>">
	                                                        </td>
											        		
											        		<td class="fixation2">
									        					<label class="radio-inline">
														  			<input type="radio" name="packagePostageDetailModelDetailList[${item_index}].mileRadio" value="1" <#if packagePostageModel.task=='add'>checked</#if><#if item.mileRadio??><#if item.mileRadio==1><#if packagePostageModel.type==1>checked</#if></#if></#if>  required onclick="$('#lc_mileage${item_index}').attr('required','required');"> 按固定里程
																</label>
																<input id="lc_mileage${item_index}" type="number" name="mileage${item_index}" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" value="<#if item.mileage??>${item.mileage}</#if>" <#if item.mileRadio??><#if item.mileRadio==1>required</#if></#if>> 公里收费
										        		        <input type="hidden" name="packagePostageDetailModelDetailList[${item_index}].mileage" value="<#if item.mileage??>${item.mileage}</#if>">
																
																<label class="radio-inline">
														  			<input type="radio" name="packagePostageDetailModelDetailList[${item_index}].mileRadio" value="2" <#if item.mileRadio??><#if item.mileRadio==2><#if packagePostageModel.type==1>checked</#if></#if></#if>  required onclick="$('#lc_mileage${item_index}').removeAttr('required');"> 按单位里程收费
																</label>
															</td>
															
															<td class="fixation3">
																每次加收<input type="number" name="extracharge${item_index}" class="form-control" placeholder="" onchange="$(this).next().val($(this).val()*100)" value="<#if item.extracharge??><#if packagePostageModel.type==1>${item.extracharge/100}</#if></#if>">元
																<input type="hidden" name="packagePostageDetailModelDetailList[${item_index}].extracharge" value="<#if item.extracharge??><#if packagePostageModel.type==1>${item.extracharge}</#if></#if>">
															</td>
															
															<td class="sheet-tableAction sheet-trDel"><i class="fa fa-times"></i></td>
											        	</tr>
											          </#if>	
									        	    </#list> 
									        	    </#if>
									        	</tbody>
									        	
									        	<tr>
									        	    <!--为了书写方便把最后一个阶梯参数下表设为0,第一个下标从1开始  -->
									        		<td class="inputTd">
									        		   <input type="number"  name="lower0" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" value="<#if detailList[0].lower??><#if packagePostageModel.type==1>${detailList[0].lower}</#if></#if>" required>公里&nbsp;以上
									        		   <input type="hidden"  name="packagePostageDetailModelDetailList[0].lower" value="<#if detailList[0].lower??><#if packagePostageModel.type==1>${detailList[0].lower}</#if></#if>">
									        		</td>
									        		
									        		<td class="radioTd">
									        			<label class="radio-inline">
														  <input type="radio" name="packagePostageDetailModelDetailList[0].mileRadio" value="1" <#if packagePostageModel.task=='add'>checked</#if><#if detailList[0].mileRadio??><#if detailList[0].mileRadio==1><#if packagePostageModel.type==1>checked</#if></#if></#if>  required onclick="$('#lc_mileage0').attr('required','required');"> 按固定里程
														</label>
														<input id="lc_mileage0" type="number" name="mileage0" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" value="<#if detailList[0].mileage??><#if packagePostageModel.type==1>${detailList[0].mileage}</#if></#if>" <#if detailList[0].mileRadio??><#if detailList[0].mileRadio==1>required</#if></#if>>公里收费
													   	<input type="hidden" name="packagePostageDetailModelDetailList[0].mileage" value="<#if detailList[0].mileage??><#if packagePostageModel.type==1>${detailList[0].mileage}</#if></#if>">
													   
														<label class="radio-inline">
														  <input type="radio" name="packagePostageDetailModelDetailList[0].mileRadio" value="2" <#if detailList[0].mileRadio??><#if detailList[0].mileRadio==2><#if packagePostageModel.type==1>checked</#if></#if></#if>  required onclick="$('#lc_mileage0').removeAttr('required');"> 按单位里程收费
														</label>
													</td>
													
													<td class="radioTd">
														每次加收<input type="number" name="extracharge0" class="form-control" placeholder="" onchange="$(this).next().val($(this).val()*100)" value="<#if detailList[0].extracharge??><#if packagePostageModel.type==1>${detailList[0].extracharge/100}</#if></#if>">元
														<input type="hidden" name="packagePostageDetailModelDetailList[0].extracharge" value="<#if detailList[0].extracharge??><#if packagePostageModel.type==1>${detailList[0].extracharge}</#if></#if>">
													</td>
													
													<td class="fixation4">
													</td>
									        	</tr>
									        </table>
									    </div>
									  </div>
								  </div>
								  
								  <!-- 复制块 -->
								  <div>
								    <table>
								  		 <tbody id="cloneBox" style="display: none;">
									        		<tr class="plusContent">
										        		<td class="fixation">
                                                            <input type="number" name="lower" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" required>公里 &nbsp;至
										        		    <input type="hidden" id="clonelower">
										        		    <input type="number" name="upper" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())" required>公里
										        		    <input type="hidden" id="cloneupper">
                                                        </td>
                                                        
										        		<td class="fixation2">
									        				<label class="radio-inline">
														  		<input type="radio" name="mileRadio" value="1" onchange="$(this).next().val($(this).val())" checked required > 按固定里程
														  		<input type="hidden" id="clonemileRadio">
															</label>
															<input type="number" name="mileage" class="form-control" placeholder="" onchange="$(this).next().val($(this).val())">公里收费
									        		        <input type="hidden" id="clonemileage">
									        		        
															<label class="radio-inline">
														  		<input type="radio" name="mileRadio" value="2" onchange="$(this).next().val($(this).val())" required > 按单位里程收费
														  		<input type="hidden" id="clonemileRadio">
															</label>
														</td>
														
														<td class="fixation3">
															每次加收<input type="number" name="extracharge" class="form-control" placeholder="" onchange="$(this).next().val($(this).val()*100)">元
									        		        <input type="hidden" id="clonecharge">
														</td>
														
														<td class="sheet-tableAction sheet-trDel"><i class="fa fa-times"></i></td>
										        	</tr>		
									        	</tbody>
								    </table>
								  </div>
								  
								  <div class="form-group">
									    <label class="col-sm-3 control-label">收费对象<span class="fill-must">*</span></label>
									    <div class="col-sm-8">
											<label class="radio-inline">
											  <input type="radio" name="publicCharge" class="toggleBtn" value="0"  <#if packagePostageModel.task=='add'>checked</#if><#if packagePostageModel.publicCharge??><#if packagePostageModel.publicCharge==0>checked</#if></#if> required> 个人账户
											</label>
											<label class="radio-inline">
											  <input type="radio" name="publicCharge" class="toggleBtn2" value="1"  <#if packagePostageModel.publicCharge??><#if packagePostageModel.publicCharge==1>checked</#if></#if> required> 对公账户
											</label>
									    </div>
									</div>
									
									
									
									<div id="bill" class="toggleContent form-group <#if packagePostageModel.task=='add'>hide</#if><#if packagePostageModel.publicCharge??><#if packagePostageModel.publicCharge==0>hide</#if></#if>">																		    
										    <label class="col-sm-3 control-label">是否允许挂账<span class="fill-must">*</span></label>
										    <div class="col-sm-7">
										    	<label class="radio-inline">
										    	  <input type="radio" name="bill" value="1"    <#if packagePostageModel.bill??><#if packagePostageModel.bill==1>checked</#if><#else>checked</#if> required> 允许
												</label>
												<label class="radio-inline">
												  <input type="radio" name="bill" value="0"    <#if packagePostageModel.bill??><#if packagePostageModel.bill==0>checked</#if></#if> required> 不允许
												</label>
										    </div>
								  </div>
									  
								  <div class="form-group">
								    <label class="col-sm-3 control-label">生效周期<span class="fill-must">*</span></label>
								    <div class="col-sm-8">
								    	<div class="sheet-inputContent">生效日期</div>
								        <label class="radio-inline">
										  <input type="radio" name="beginTimeRadio" id="" value="1" <#if packagePostageModel.task=='add'>checked</#if><#if packagePostageModel.beginTimeRadio??><#if packagePostageModel.beginTimeRadio==1>checked</#if></#if> required> 即时生效
										</label>
										<label class="radio-inline">
										  <input type="radio" name="beginTimeRadio" id="" value="2" style="margin-top: 10px;" <#if packagePostageModel.beginTimeRadio??><#if packagePostageModel.beginTimeRadio==2>checked</#if></#if> required> 
										  <input type="text"  name="beginTime" id="beginTime" class="form-control" placeholder="请选择生效时间" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" value="<#if packagePostageModel.beginTime??>${packagePostageModel.beginTime}</#if>">
										</label>
								    </div>
								    
								     <div class="col-sm-offset-3 col-sm-8">
								    	<div class="sheet-inputContent">截止日期</div>
								        <label class="radio-inline">
										  <input type="radio" name="endTimeRadio" id="" value="1" <#if packagePostageModel.task=='add'>checked</#if><#if packagePostageModel.endTimeRadio??><#if packagePostageModel.endTimeRadio==1>checked</#if></#if> required> 不限日期
										</label>
										<label class="radio-inline">
										  <input type="radio" name="endTimeRadio" id="" value="2" style="margin-top: 10px;" <#if packagePostageModel.endTimeRadio??><#if packagePostageModel.endTimeRadio==2>checked</#if></#if> required> 
										  <input type="text" name="endTime" id="endTime" class="form-control" placeholder="请选择截止日期" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" value="<#if packagePostageModel.endTime??>${packagePostageModel.endTime}</#if>">
										</label>
								    </div>
								  </div> 

									<div class="form-group">
										<div class="col-sm-offset-4 col-sm-3 sheet-btnBar">
											<button type="button" class="btn btn-info sheet-btn" onclick="submitFormdata()">保存</button>
											<button type="button" class="btn btn-default sheet-btn" onclick="closeDialog()">取消</button>
										</div>
									</div>

									<div class="form-group" style="display: none">
										<div class="col-sm-offset-4 col-sm-3 error-resgister">
											<span id="errorContent">错误提示错误提示错误提示</span>
											<!-- 错误提示 -->
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
 	</div>
 	
<script>

	  $(document).ready(function() {
		  
		    var type="<#if packagePostageModel.type??>${packagePostageModel.type}</#if>";
		    var publicCharge="<#if packagePostageModel.publicCharge??>${packagePostageModel.publicCharge}</#if>";
		    var provinceids="<#if packagePostageModel.provinceids??>${packagePostageModel.provinceids}</#if>";
		    var publicChargebtn=$('input:radio[name="publicCharge"]').val();
		    var task=GetQueryString("task");
	    	
		    var toggleContent=$(".toggleContent");
		    if(publicCharge=="0"){
		    	toggleContent.addClass("hide");
	    	}
	    	
		    if(type=="1"||type==""){
		    	$(".role1").css("display","block");
		    	$(".role2").css("display","none");
		    	$(".role2").find("input").attr("disabled",true);	
		    }else if(type=="2"){
		       	$(".role1").css("display","none");
		     	$(".role2").css("display","block");
				$(".role1").find("input").attr("disabled",true);   
		    }

		    /* if(task=='add'){
		    	$(".areaRadio").change(function() {
    				var selectedvalue = $("input[name='areaRadio']:checked").val();
    				alert(selectedvalue);
    				if (selectedvalue == 1) {
    					$("#provinceids").attr("disabled","disabled");
    			    	$("#cityids").attr("disabled","disabled");
    				}else {
    					$("#provinceids").removeAttr("disabled");
    					$("#cityids").removeAttr("disabled");
    				}
    			});
			} */

		    if(task=="add"){
		    	$("input[name='bill']:eq(0)").attr("checked","checked"); 
			}
		    
		    dataform=$("#dataform").validate();
		 	selectEvent();//下拉框多选
		  	sheetTrAction();//增加、删除 一行阶梯费用
		  	if(task=="edit"){
			    $('#provinceids').val('<#if packagePostageModel.provinceids??>${packagePostageModel.provinceids}</#if>'.split(","));
	            $('#provinceids').multiselect("refresh");  
	            setCitymultiselect();
			    $('#cityids').val('<#if packagePostageModel.cityids??>${packagePostageModel.cityids}</#if>'.split(","));
	            $('#cityids').multiselect("refresh");  
			}  

            cityRadioEvent();
	  }); 

	  function cityRadioEvent(){
	  	  //选择地区初始化
		  var customRadio=$("#customRadio").attr("checked");
		  if(customRadio=="checked"){
		  		$("#proCityBox").css("display","block");
		  }
	  	  //选择地区radio
		  $("#customRadio").on("click",function(){
		  	var customRadio=$("#customRadio").attr("checked");
		  	if(customRadio=="checked"){
		  		$("#proCityBox").css("display","block");
		  	}
		  });
		  
		  //全地区初始化
		  	var allRadio=$("#allRadio").attr("checked");
		  	if(allRadio=="checked"){
		  		$("#proCityBox").css("display","none");
		  	}
		  //全地区radio
		 $("#allRadio").on("click",function(){
		  	var allRadio=$("#allRadio").attr("checked");
		  	if(allRadio=="checked"){
		  		$("#proCityBox").css("display","none");
		  	}
		 });
		  
	  }

	  function GetQueryString(name)
	  {
	       var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	       var r = window.location.search.substr(1).match(reg);
	       if(r!=null)return  unescape(r[2]); return null;
	  }
 
	  function selectEvent(){
		  
		    combox("provinceids","Province",null,null,true);
	  		
		    $("#provinceids").multiselect({
	  			noneSelectedText: "===请选择===",
	  			checkAllText:"全选",
	  			uncheckAllText:"全不选" ,
	  			uncheckAll: function(event, ui){
	  				setCitymultiselect();
	  	        },
	  	      	/*selectedText:function(numChecked, numAll, chkItems) {
  					setCitymultiselect();
  					return "选中【"+numChecked+"】项 ,共【 "+numAll+"】项";
  	        	}*/
  	        
  	        	close:function(){
  	        		setCitymultiselect();
  	        	},
  	         	selectedText: '选中 # 个省',
  	        	selectedList: 5
	  	        
	  		});
		    setCitymultiselect();
	  }
	  
	  function setCitymultiselect(){
			var provincesids= $("#provinceids").multiselect().multiselect("getChecked").map(function() {
	                return this.value;
	            }).get();
				
				 $("#cityids").multiselect().multiselect("destroy").hide();
				 combox("cityids","City",provincesids,null,true);
		  		 $("#cityids").multiselect({
		  			noneSelectedText: "===请选择===",
		  			checkAllText:"全选",
		  			uncheckAllText:"全不选",
		  			
		  			selectedText:'选中 # 个市',
		  		    selectedList: 5
		  		 });
	  }
	  
	  //指定动态增加的输入框的下表编号
	  var index=parseInt("<#if detailList?? && packagePostageModel.type==1>${detailList?size}<#else>2</#if>");
	  var index2=parseInt("<#if detailList?? && packagePostageModel.type==2>${detailList?size}<#else>2</#if>");
	
	  function sheetTrAction(){
	  	//增加一行阶梯费用
	  	//按里程
	  	var tbody=$("#sheet-tbody");
	  	var tbody2=$("#sheet-tbody2");
	  	$("#sheet-trPlus").on("click",function(){
	  		var plusContent=$("#cloneBox .plusContent").clone(true);
	  		
		  	   var  clonelower=$(plusContent).find('#clonelower');
		       clonelower.attr('name','packagePostageDetailModelDetailList['+(index)+'].lower');
		       clonelower.prev().attr('name','lower'+index);
		       
		       var  cloneupper= $(plusContent).find('#cloneupper');
		       cloneupper.attr('name','packagePostageDetailModelDetailList['+(index)+'].upper');
		       cloneupper.prev().attr('name','upper'+index);

		       var  clonemileRadio=$(plusContent).find('#clonemileRadio');
		       clonemileRadio.attr('name','packagePostageDetailModelDetailList['+(index)+'].mileRadio');
		       clonemileRadio.prev().attr('name','mileRadio'+index);
		       
		       var  clonemileage=$(plusContent).find('#clonemileage');
		       clonemileage.attr('name','packagePostageDetailModelDetailList['+(index)+'].mileage');
		       clonemileage.prev().attr('name','mileage'+index);

		       var  clonecharge=$(plusContent).find('#clonecharge');
		       clonecharge.attr('name','packagePostageDetailModelDetailList['+(index)+'].extracharge');
		       clonecharge.prev().attr('name','extracharge'+index);
		  	   tbody.append(plusContent); 
		  	   index=index+1;
	  	});
	  	//按次
	  	$("#sheet-trPlus2").on("click",function(){
	  		var plusContent2=$("#cloneBox .plusContent2").clone(true);
	  		
	  		$(plusContent2).find('#clonelower').attr('name','packagePostageDetailModelDetailList['+index2+'].lower');
	  		$(plusContent2).find('#cloneupper').attr('name','packagePostageDetailModelDetailList['+index2+'].upper');
	  	 
	  	    var  cloneprice=$(plusContent2).find('#cloneprice');
	        cloneprice.attr('name','packagePostageDetailModelDetailList['+(index2)+'].price');
	        cloneprice.prev().attr('name','price'+(index2));
	        
	  		tbody2.append(plusContent2); 
	  		index2=index2+1;
	  	});
	  	
	  	//删除当前行阶梯费用
	  	$(".plusContent .sheet-trDel").on("click",function(){
	  		var plusContent=$(this).parent().remove();
		  	$("#sheet-tbody .plusContent").each(function(i,domEle){
		  	   var  clonelower=$(this).find('#clonelower');
		       clonelower.attr('name','packagePostageDetailModelDetailList['+(i+2)+'].lower');
		       clonelower.prev().attr('name','lower'+(i+2));
		       
		       var  cloneupper= $(this).find('#cloneupper');
		       cloneupper.attr('name','packagePostageDetailModelDetailList['+(i+2)+'].upper');
		       cloneupper.prev().attr('name','upper'+(i+2));
		       
		       var  cloneprice=$(this).find('#cloneprice');
		       cloneprice.attr('name','packagePostageDetailModelDetailList['+(i+2)+'].price');
		       cloneprice.prev().attr('name','price'+(i+2));

		       var  clonecharge=$(this).find('#clonecharge');
		       clonecharge.attr('name','packagePostageDetailModelDetailList['+(i+2)+'].extracharge');
		       clonecharge.prev().attr('name','extracharge'+(i+2));
		  	});
			index=index-1;
	  	});
	  	$(".plusContent2 .sheet-trDel").on("click",function(){
	  		var plusContent=$(this).parent().remove();
		  	$("#sheet-tbody2 .plusContent2").each(function(i,domEle){
		  	    $(this).find('#clonelower').attr('name','packagePostageDetailModelDetailList['+(i+2)+'].lower');
		  	    $(this).find('#cloneupper').attr('name','packagePostageDetailModelDetailList['+(i+2)+'].upper');
		        
		  	    var  cloneprice=$(this).find('#cloneprice');
		        cloneprice.attr('name','packagePostageDetailModelDetailList['+(i+2)+'].price');
		        cloneprice.prev().attr('name','price'+(i+2));
		  	});
			index2=index2-1;
	  	});
	  }
	  
	  var dataform;
	  function submitFormdata(){
		  
		     var task=getUrlParamVal('task');
		     
		     dataform.form();
    	     if(dataform.valid()){
                var a,url;
                var nowtime = new Date();
                var strtemp = ""+nowtime.getHours()+nowtime.getMinutes()+nowtime.getSeconds()+nowtime.getMilliseconds();
                a=strtemp;

                if(task=='add'){
                	url= "${base}/add_package_postage/" + a;
                }else if(task=='edit'){
                	url= "${base}/edit_package_fare";
                }
                
                $("#loading").showLoading(); 
        		$.ajax({  
	      		      type : "POST",  
	      		      url : url,
	      		      dataType : "json",  
	      		      data:  $("#dataform").serialize(),
	      		      success : function(data) {  
	      		       	    $('#loading').hideLoading();
		      		        if(data.result == true) {
	   
		      			         jAlert("操作成功！","提示", function() {
		      			            parent.window.opener.location.reload();
		                            closeDialog();
		      		             });
	                           
	                        }else if(data.result == false){
	                        	 jAlert("未知错误！");
	                        }
	                        	
	      		      }  
      		    }); 	    	
    	    }
		  
	  }
</script>
</body>